<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

</head>

<body>
    <h3>get请求和post请求</h3>
    <button onclick="get();">发送get请求</button>
    <button onclick="post();">发送post请求</button>

    <script>
        function get() {
            $.ajax({
                type: 'get',
                url: 'http://localhost:3000/demo3',
                data: {
                    aa: '1111',
                    bb: '2222'
                },
                dataType: 'json',
                success: function(res) {
                    console.log(res);
                },
                error: function(err) {
                    console.log(err);
                }
            })
        }

        function post() {
            $.ajax({
                type: 'post',
                url: 'http://localhost:3000/demo3',
                data: {
                    aa: '3333',
                    bb: '4444'
                },
                dataType: 'json',
                success: function(res) {
                    console.log(res);
                },
                error: function(err) {
                    console.log(err);
                }
            })
        }
    </script>
</body>

</html>